<?php
include_once "../config/config.php";
include_once "../lib/pdodbmanager.php";
include_once "../lib/functions.php";
include_once "../lib/senitize.php";
$pdo_obj=new PDODBMNanager(HOST,DB,USERNAME,PASS);


//$pdfname="trainer_feedback_report.pdf";
//$pdfname=str_ireplace("_","",$pdfname);
$total_strongly_agree=0;
$total_agree=0;
$total_neutral=0;
$total_poor=0;
$total_very_poor=0;

$feedbackquestion="select * from feedbackquestions where status=1";
//$feedbackquestion=$_POST['feedbackquestion'];
$feedbackquestion=$pdo_obj->selectdata($feedbackquestion);

$selecttrainerfeedback="select trainer_feedbacks.id,first_name,last_name,code from trainer_feedbacks,users where users.id=trainer_feedbacks.trainer_id and trainer_id='".$_POST['trainer_eid']."' ";
//$selecttrainerfeedback=$_POST['selecttrainerfeedback'];
$selecttrainerfeedback=$pdo_obj->selectdata($selecttrainerfeedback);
?>
<?php $msg= trim($selecttrainerfeedback[0]['first_name']." ".$selecttrainerfeedback[0]['last_name'])." ( ".$selecttrainerfeedback[0]['code']." )" ?>
<style type="text/css">
table
{
    width:  100%;
    
    border-collapse: collapse;
    
}
td
{
	padding:5px;
}
</style>
<page orientation="paysage">
<br>

<div style="font-size: 22px; font-weight: bold;margin: auto;width:650px;position: relative;border:0px solid"><u><?php echo $msg." Feedback Summarized Report"; ?></u><br></div><br><br>

				
				
				<table cellspacing="0" cellpadding="0" style="border-color:#888888;" border="1">
					<?php
						$trainerfeedbacksids="";
						for($i=0;$i<count($selecttrainerfeedback);$i++)
						{
							$trainerfeedbacksids.=$selecttrainerfeedback[$i]['id'].",";
						}
						$trainerfeedbacksids=substr($trainerfeedbacksids,0,(strlen($trainerfeedbacksids)-1));
					?>
					<?php
						if(count($feedbackquestion)>0)
						{
							?>
						<tr style="background:#888888;color:#FFF;border:1px solid #888888">
							<td style="width:475px"><b>Evaluation Question</b></td>
							<td style="width:100px"><b>Strongly Agree/Excellent</b></td>
							<td style="width:75px"><b>Agree/Good</b></td>
							<td style="width:100px"><b>Neutral/Average</b></td>
							<td style="width:90px"><b>Disagree/Poor</b></td>
							<td style="width:100px"><b>Strongly Disagree/Very Poor</b></td>
						</tr>
						<?php
							for($i=0;$i<count($feedbackquestion);$i++)
							{
							?>
							<tr>
								<td ><?php echo ($i+1)." ".$feedbackquestion[$i]['question']; ?>
													
								</td>
								<td style="text-align:center;">
								<?php
								$feedbackquestionstatus="select count(id) as num from trn_feedback where trainer_feedbacksid in ('".$trainerfeedbacksids."') and feedback_questionid='".$feedbackquestion[$i]['id']."' and (feedback='Strongly Agree' or feedback='Excellent') ";
								$feedbackquestionstatus=$pdo_obj->selectdata($feedbackquestionstatus);
								echo $feedbackquestionstatus[0]['num'];
								$total_strongly_agree+=$feedbackquestionstatus[0]['num'];
								?>
								</td>
								<td style="text-align:center;"><?php
								$feedbackquestionstatus="select count(id) as num from trn_feedback where trainer_feedbacksid in ('".$trainerfeedbacksids."') and feedback_questionid='".$feedbackquestion[$i]['id']."' and (feedback='Agree' or feedback='Good') ";
								$feedbackquestionstatus=$pdo_obj->selectdata($feedbackquestionstatus);
								echo $feedbackquestionstatus[0]['num'];
								$total_agree+=$feedbackquestionstatus[0]['num'];
								?></td>
								<td style="text-align:center;"><?php
								$feedbackquestionstatus="select count(id) as num from trn_feedback where trainer_feedbacksid in ('".$trainerfeedbacksids."') and feedback_questionid='".$feedbackquestion[$i]['id']."' and (feedback='Neutral' or feedback='Average') ";
								$feedbackquestionstatus=$pdo_obj->selectdata($feedbackquestionstatus);
								echo $feedbackquestionstatus[0]['num'];
								$total_neutral+=$feedbackquestionstatus[0]['num'];
								?></td>
								<td style="text-align:center;"><?php
								$feedbackquestionstatus="select count(id) as num from trn_feedback where trainer_feedbacksid in ('".$trainerfeedbacksids."') and feedback_questionid='".$feedbackquestion[$i]['id']."' and (feedback='Disagree' or feedback='Poor') ";
								$feedbackquestionstatus=$pdo_obj->selectdata($feedbackquestionstatus);
								echo $feedbackquestionstatus[0]['num'];
								$total_poor+=$feedbackquestionstatus[0]['num'];
								?></td>
								<td style="text-align:center;"><?php
								$feedbackquestionstatus="select count(id) as num from trn_feedback where trainer_feedbacksid in ('".$trainerfeedbacksids."') and feedback_questionid='".$feedbackquestion[$i]['id']."' and (feedback='Strongly Disagree' or feedback='Very Poor') ";
								$feedbackquestionstatus=$pdo_obj->selectdata($feedbackquestionstatus);
								echo $feedbackquestionstatus[0]['num'];
								$total_very_poor+=$feedbackquestionstatus[0]['num'];
								?></td>
							</tr>	
							<?php
							}
					}
					else
					{
					}		
					?>
				</table>

	



</page>
